#include <public/config.h>
#include <public/uart_dev_getchar.h>
#include <public/basic_types.h>

#define STATUS_REG_OFFSET	0x04
#define DATA_REG_OFFSET	0x00
#define UART_DRA	0x01

//void uart_dev_getchar(uint8_t *car)
//{
//	volatile uint32_t uart_status;
//	uint8_t carAux;
//	/*  Waiting for ready data in the a channel */
//	while(!((uart_status = UART_REGISTER(STATUS_REG_OFFSET)) & UART_DRA));
//	carAux = (uint8_t) UART_REGISTER(DATA_REG_OFFSET);
//	*car = (uint8_t) UART_REGISTER(DATA_REG_OFFSET);
//
//}

uint8_t sgi_uart_getchar()
{
	volatile uint32_t uart_status;

	/*  Waiting for ready data in the a channel */
	while(!((uart_status = SGI_UART_REGISTER(STATUS_REG_OFFSET)) & UART_DRA));
	return (uint8_t) SGI_UART_REGISTER(DATA_REG_OFFSET);
}

uint8_t ssi_uart_getchar()
{
	volatile uint32_t uart_status;

	/*  Waiting for ready data in the a channel */
	while(!((uart_status = SSI_UART_REGISTER(STATUS_REG_OFFSET)) & UART_DRA));
	return (uint8_t) SSI_UART_REGISTER(DATA_REG_OFFSET);
}
